package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqWarehousing;
import com.drug.mingkang.mapper.HqWarehousingMapper;
import com.drug.mingkang.model.vo.MaterialInventoryDetailVo;
import com.drug.mingkang.service.HqWarehousingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 入库明细(HqWarehousing)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:13
 */
@Service("hqWarehousingService")
public class HqWarehousingServiceImpl implements HqWarehousingService {
    @Resource
    private HqWarehousingMapper hqWarehousingMapper;

    @Override
    public List<MaterialInventoryDetailVo> selectMaterialInventoryDetailAll(MaterialInventoryDetailVo vo) {
        return this.hqWarehousingMapper.selectMaterialInventoryDetailAll(vo);
    }

    @Override
    public int selectMaterialInventoryDetailCount(MaterialInventoryDetailVo vo) {
        return this.hqWarehousingMapper.selectMaterialInventoryDetailCount(vo);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param wareId 主键
     * @return 实例对象
     */
    @Override
    public HqWarehousing queryById(String wareId) {
        return this.hqWarehousingMapper.queryById(wareId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqWarehousing> queryAllByLimit(int offset, int limit) {
        return this.hqWarehousingMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqWarehousing 实例对象
     * @return 实例对象
     */
    @Override
    public HqWarehousing insert(HqWarehousing hqWarehousing) {
        this.hqWarehousingMapper.insert(hqWarehousing);
        return hqWarehousing;
    }

    /**
     * 修改数据
     *
     * @param hqWarehousing 实例对象
     * @return 实例对象
     */
    @Override
    public HqWarehousing update(HqWarehousing hqWarehousing) {
        this.hqWarehousingMapper.update(hqWarehousing);
        return this.queryById(hqWarehousing.getWareId());
    }

    /**
     * 通过主键删除数据
     *
     * @param wareId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String wareId) {
        return this.hqWarehousingMapper.deleteById(wareId) > 0;
    }


    /**
     * 批量增加
     * @param list
     * @return
     */
    @Override
    public int insertBatch(List<HqWarehousing> list) {
        return this.hqWarehousingMapper.insertBatch(list);
    }
}